Dynomotion

Group: DynoMotion Message: 12641 From: Tom Kerekes Date: 12/29/2015
Subject: Re: KStep Spindle Control Example - UserData[1] array is empty
Hi,

Are you configuring KMotionCNC | Tool Setup | M0-M30 | S for this program and to use Var=1?

Are you executing a GCode line with an S1200 in it?

Regards
TK

On 12/29/2015 12:33 PM, seanstumpf@... [DynoMotion] wrote:
 

Afternoon all,

I use the example code below and nothing happens. I printed the persist.UserData[1] array to console and its empty. When I hard code 'speed = 12000' everything hardware wise works as it should and my VFD drive goes to the appropriate HZ (in this case 200hz).

What am I missing? When and where is persist.UserData[1] updated with the current Gcode Speed value? Is this something I have to add somewhere else? I don't see any sign of it in any of the default config files either.

main()
{
    float speed = *(float *)&persist.UserData[1];  // value stored is actually a float

    printf("speed=%f UserData1=%f\n",speed,persist.UserData[1]);

    FPGA(KAN_TRIG_REG)=4;              // Mux PWM0 to JP7 Pin5 IO 44 for KSTEP
    SetBitDirection(44,1);          // define bit as an output
    FPGA(IO_PWMS_PRESCALE) = 46;      // divide clock by 46 (1.4 KHz)
    FPGA(IO_PWMS+1) = 1;              // Enable
   
    FPGA(IO_PWMS) = CorrectAnalog(speed/RPM_FACTOR);      // Set PWM
}


If i do this everything works hardware wise. So all my connections are good.


main()
{
    float speed = *(float *)&persist.UserData[1];  // value stored is actually a float


    printf("speed=%f UserData1=%f\n",speed,persist.UserData[1]);

    speed = 12000;

    printf("speed=%f\n,speed);


    FPGA(KAN_TRIG_REG)=4;              // Mux PWM0 to JP7 Pin5 IO 44 for KSTEP
    SetBitDirection(44,1);          // define bit as an output
    FPGA(IO_PWMS_PRESCALE) = 46;      // divide clock by 46 (1.4 KHz)
    FPGA(IO_PWMS+1) = 1;              // Enable
   
    FPGA(IO_PWMS) = CorrectAnalog(speed/RPM_FACTOR);      // Set PWM

}